package com.beidasoft.web.model.system;

import java.util.Calendar;

public class KafkaMessage {
    private Integer messageIndex;//消息序列号
    private String createTime;//消息触发时间
    private Integer isNeedPreMsg;//是否有前置消息完成要求（1：有，2：没有）
    private Integer preMsgIndex;//前置消息序列号
    private String messageType;//(01:数据同步 02:消息通知)
    private String optType;//(01:insert;02:update;03:logic delete;04:physics delete)
    private String extraFlag;//用于辅助信息传递的字段，根据协议双方商议自定义内容规则
    private String data;//数据内容，以 jsonArray string的形式存储
    private String topic;//消息队列主题

    public KafkaMessage() {

    }

    public KafkaMessage(Integer isNeedPreMsg, Integer preMsgIndex, String messageType
            , String optType, String extraFlag, String topic, String data) {
        this.messageIndex = generalMessageIndex();
        this.isNeedPreMsg = isNeedPreMsg;
        this.preMsgIndex = preMsgIndex;
        this.messageType = messageType;
        this.topic = topic;
        this.optType = optType;
        this.extraFlag = extraFlag;
        this.data = data;
    }

    public Integer generalMessageIndex() {
        Calendar cal = Calendar.getInstance();
        Integer mi = (int) (cal.getTimeInMillis() * 100000 + (Math.random() * 9 + 1) * 100000);
        return mi;
    }

    public Integer getMessageIndex() {
        return messageIndex;
    }

    public void setMessageIndex(Integer messageIndex) {
        this.messageIndex = messageIndex;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public Integer getIsNeedPreMsg() {
        return isNeedPreMsg;
    }

    public void setIsNeedPreMsg(Integer isNeedPreMsg) {
        this.isNeedPreMsg = isNeedPreMsg;
    }

    public Integer getPreMsgIndex() {
        return preMsgIndex;
    }

    public void setPreMsgIndex(Integer preMsgIndex) {
        this.preMsgIndex = preMsgIndex;
    }

    public String getMessageType() {
        return messageType;
    }

    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }

    public String getOptType() {
        return optType;
    }

    public void setOptType(String optType) {
        this.optType = optType;
    }

    public String getExtraFlag() {
        return extraFlag;
    }

    public void setExtraFlag(String extraFlag) {
        this.extraFlag = extraFlag;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }
}
